home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.1 KB | 35 lines | [TEXT/CWIE] |
- // --------------------------------------------------------------------------------------
- // ReturnAppName.c
- //
- // Written by Don Arbow and Marc A. Raiser, EveryDay Objects, Inc.
- // in one day - June 26, 1997
- // --------------------------------------------------------------------------------------
-
- #include <Processes.h>
- #include <Files.h>
-
- #include "ReturnAppName.h"
-
- OSErr ReturnAppName(Str255 fileName) {
-
- register int i;
- ProcessInfoRec thisProcess;
- ProcessSerialNumber process;
- FSSpec myFS;
- OSErr err = noErr;
- short fileNameLen = fileName[0];
-
- thisProcess.processAppSpec = &myFS; /* Aim pointer at our storage */
- thisProcess.processInfoLength = sizeof(ProcessInfoRec); /* Store record size */
- thisProcess.processName = (unsigned char *) NewPtr(32); /* Allocate room for the name */
- process.highLongOfPSN = 0; /* Clear out process serial number */
- process.lowLongOfPSN = kCurrentProcess;
-
- err = GetProcessInformation(&process, &thisProcess);
-
- if (err == noErr) {
- BlockMoveData(myFS.name + 1, fileName + fileNameLen + 1, *(myFS.name));
- fileName[0] += myFS.name[0];
- }
- return err;
- }